package responsibilityChain;

public class Client {

    public static void main(String[] args) {
        PurchaseRequest purchaseRequest = new PurchaseRequest("订书", 80000);

        //创建相关的审批人
        DepartmentApprover departmentApprover = new DepartmentApprover("张主任");
        CollegeApprover collegeApprover = new CollegeApprover("李院长");
        SchoolApprover schoolApprover = new SchoolApprover("吴校长");

        //创建职责链
        departmentApprover.setApprover(collegeApprover);
        collegeApprover.setApprover(schoolApprover);
        schoolApprover.setApprover(departmentApprover);

        //职责链形成闭环，无论哪一个对象执行处理方法，都会找到相应的对象来处该方法
        departmentApprover.processRequest(purchaseRequest);
        collegeApprover.processRequest(purchaseRequest);
        schoolApprover.processRequest(purchaseRequest);
    }

}
